<template>
  <el-row v-if="$route.path === '/caption/assets'">
    <el-col :span="24">
      <form class="el-form query-form el-form--label-right el-form--inline">
        <div class="el-form-item el-form-item--medium" v-if="admin.mType == 2 || admin.mType == 3">
          <label for="name" class="el-form-item__label" style="width: 60px;">区</label>
          <div class="el-form-item__content">
            <div class="el-input el-input--medium">
              <el-select v-model="query.mRegion" placeholder="惠济区" @change="get_townAtt()">
                <el-option label="惠济区" value="1349"></el-option>
              </el-select>
            </div>
          </div>
        </div>
        <div class="el-form-item el-form-item--medium" v-if="!(admin.mType >= 4)">
          <label for="date" class="el-form-item__label" style="width: 60px;">街道</label>
          <div class="el-form-item__content">
            <el-select
              v-model="query.mZhenid"
              clearable
              placeholder="请选择想要查看的街道"
              @change="get_villageAtt()"
            >
              <el-option
                v-for="(town, index) in townAtt"
                :key="index"
                :label="town.zName"
                :value="town.zhenId"
              ></el-option>
            </el-select>
          </div>
          <!---->
        </div>
        <div class="el-form-item el-form-item--medium" v-if="!(admin.mType == 5)">
          <label for="date" class="el-form-item__label" style="width: 60px;">村</label>
          <div class="el-form-item__content">
            <el-select
              v-model="query.mVillageid"
              clearable
              placeholder="请选择想要查看的村"
              @change="get_aType()"
            >
              <el-option
                v-for="(village, index) in villageAtt"
                :key="index"
                :label="village.vName"
                :value="village.villageId"
              ></el-option>
            </el-select>
          </div>
          <!---->
        </div>

        <div class="el-form-item el-form-item--medium ml-6">
          <!---->
          <div class="el-form-item__content">
            <el-button type="primary" icon="el-icon-search" @click="to_query">搜索</el-button>
            <!---->
          </div>
        </div>
        <div class="el-form-item el-form-item--medium ml-9" v-if="!(admin.mType == 3)">
          <div class="el-form-item__content">
            <el-button plain icon="el-icon-plus" @click="show_form()">
              <span>添加</span>
            </el-button>
          </div>
          <!---->
        </div>
      </form>
    </el-col>
    <el-col :span="24">
      <el-table
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(225, 225, 225, 0.8)"
        ref="multipleTable"
        :data="items"
        max-height="600"
        border
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="120" align="center"></el-table-column>
        <el-table-column type="index" width="120" align="center"></el-table-column>
        <el-table-column label="资产名称" width="340" align="center" prop="zcmzName"></el-table-column>
        <el-table-column label="资产类型" width="340" align="center" prop="assets.aType"></el-table-column>
        <el-table-column label="所属村" width="240" align="center" prop="villName"></el-table-column>
        <el-table-column label="编辑" align="center" width="350" fixed="right">
          <template slot-scope="scope" v-if="$route.path === '/caption/assets'">
            <el-button type="primary" icon="el-icon-tickets" @click="updata(scope.$index, true)">详情</el-button>
            <el-button
              v-if="!(admin.mType == 3)"
              type="warning"
              icon="el-icon-edit"
              @click="updata(scope.$index)"
            >编辑</el-button>
            <el-button
              v-if="!(admin.mType == 3)"
              type="danger"
              icon="el-icon-delete"
              @click="del(scope.$index, 'zcmzName')"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <div style="margin-top: 20px">
        <el-row>
          <el-col :span="12">
            <div
              class="grid-content bg-purple d-flex jc-between ai-center"
              v-if="!(admin.mType == 3)"
            >
              <el-button
                type="primary"
                icon="el-icon-delete"
                style="display: block;"
                class="h-1 w-1"
                @click="del_multip('zcmzName')"
              ></el-button>
              <a
                target="_blank"
                href="http://www.huitengit.com/excelbiao/zichan.zip"
                class="ml-10 pl-10"
              >
                <el-button type="text" icon="el-icon-download">模板文件下载</el-button>
              </a>
              <el-select v-model="type" clearable placeholder="表类型" @change="set_src(type)">
                <el-option
                  v-for="item in [{ name: '非经营资产', value: 1 }, { name: '经营资产', value: 2 }]"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                ></el-option>
              </el-select>
              <el-upload
                class="upload-demo"
                ref="upload"
                :action="$http.defaults.baseURL + url"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :on-success="success"
                :file-list="fileList_file"
                :auto-upload="false"
                accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
                :before-upload="set_files_form"
                :data="file_form"
                name="file"
                :multiple="true"
              >
                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                <el-button
                  style="margin-left: 10px;"
                  size="small"
                  type="success"
                  @click="submitUpload"
                >上传到服务器</el-button>
                <div slot="tip" class="el-upload__tip">只能上传excel文件，建议不超过500kb</div>
              </el-upload>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple-light">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="pagination.current_page"
                :page-sizes="pagination.page_sizes"
                :page-size="pagination.page_size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pagination.total"
              ></el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-col>

    <el-dialog
      title="新增资产信息"
      v-if="$route.path === '/caption/assets'"
      width="40%"
      :show-close="false"
      :close-on-click-modal="false"
      :lock-scroll="true"
      :visible.sync="dialogFormVisible_create"
    >
      <el-form
        ref="form"
        :model="form"
        label-width="5.625rem"
        class="d-flex flex-column w-10 p-2 pt-0"
      >
        <el-col :span="24">
          <el-tabs type="border-card">
            <el-tab-pane label="资产名称添加">
              <el-col :span="24" class="d-flex flex-column">
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="name" class="el-form-item__label" style="width: 5.625rem;">区</label>
                  <div class="el-form-item__content">
                    <div class="el-input el-input--medium">
                      <el-select
                        v-model="form.mRegion"
                        placeholder="惠济区"
                        @change="get_townAtt(true)"
                        disabled="true"
                      >
                        <el-option label="惠济区" value="1349"></el-option>
                      </el-select>
                    </div>
                  </div>
                </div>
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="date" class="el-form-item__label" style="width:5.625rem;">街道</label>
                  <div class="el-form-item__content">
                    <el-select
                      v-model="form.mZhenid"
                      clearable
                      placeholder="请选择想要查看的街道"
                      @change="get_villageAtt(true)"
                      :disabled="admin.mType >= 4"
                    >
                      <el-option
                        v-for="(town, index) in townAtt_form"
                        :key="index"
                        :label="town.zName"
                        :value="town.zhenId"
                      ></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">村</label>
                  <div class="el-form-item__content">
                    <el-select
                      v-model="form.villageId"
                      clearable
                      placeholder="请选择想要查看的村"
                      @change="get_groupAtt(true)"
                      :disabled="admin.mType == 5"
                    >
                      <el-option
                        v-for="(village, index) in villageAtt_form"
                        :key="index"
                        :label="village.vName"
                        :value="village.villageId"
                      ></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">组名</label>
                  <div class="el-form-item__content">
                    <el-select v-model="form.zuId" clearable placeholder="请选择">
                      <el-option
                        v-for="(group, index) in groupAtt_form"
                        :key="index"
                        :label="group.zName"
                        :value="group.zKey"
                      ></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">资产名称</label>
                  <div class="el-form-item__content">
                    <el-input v-model="form.zcmzName" clearable></el-input>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="非经营行资产添加">
              <el-col :span="24">
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">计量单位</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzJilangdanwei" clearable placeholder="请输入计量单位"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">单价</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzDanjian" clearable placeholder="请输入单价"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">现今价值</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzXianzhi" clearable placeholder="请输入现今价值"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">规则型号</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzXinghao" clearable placeholder="请输入规则型号"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">资产来源</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzLaiyuan" clearable placeholder="请输入资产来源"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">使用部门</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzDepartment" clearable placeholder="请输入使用部门"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">产品状态</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzZhuangtai" clearable placeholder="请输入产品状态"></el-input>
                    </div>
                  </div>
                </el-col>
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">数量</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzShuliang" clearable placeholder="请输入数量"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">变动情况</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzBiandongqingkuang"
                        clearable
                        placeholder="请输入变动情况"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">品牌</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzPinpai" clearable placeholder="请输入品牌"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">构建时间</label>
                    <div class="el-form-item__content">
                      <el-date-picker
                        v-model="form.zjtzGoujianshijian"
                        type="date"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        placeholder="选择日期"
                        clearable
                      ></el-date-picker>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">预计年限</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzYvjinianxian" clearable placeholder="请输入预计年限"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">使用人</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzPeople" clearable placeholder="请输入使用人"></el-input>
                    </div>
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24" class="mb-2">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">备注</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-input type="textarea" :rows="4" v-model="form.zjtzBeizhu"></el-input>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="经营性资产添加">
              <el-col :span="24">
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">承租人</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyChengzhuren" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同期限</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyHetongqixian" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同状态</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyZhuangtai" clearable></el-input>
                    </div>
                  </div>
                </el-col>
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">签订合同</label>
                    <div class="el-form-item__content">
                      <el-select
                        v-model="form.zcjyHetong"
                        clearable
                        placeholder="请选择想要查看的村"
                        @change="get_types(true)"
                      >
                        <el-option
                          v-for="(item, index) in [{name: '有', value: '1'}, {name: '无', value: '0'}]"
                          :key="index"
                          :label="item.name"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">支付情况</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyZhifuqinkuang" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同金额</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyHetongjine" clearable></el-input>
                    </div>
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24" class="mb-2">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">备注</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-input type="textarea" :rows="4" v-model="form.zcjyBeizhu"></el-input>
                  </div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同照片</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-upload
                      ref="upload_create"
                      list-type="picture-card"
                      :on-preview="handlePictureCardPreview"
                      :on-remove="handleRemove"
                      :before-upload="set_form"
                      :auto-upload="false"
                      :on-change="file_change"
                      :data="form"
                      :multiple="true"
                      :http-request="uploadFile"
                    >
                      <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible" size="tiny">
                      <img width="100%" v-if="form.src" :src="form.src" alt />
                    </el-dialog>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel_c">取 消</el-button>
        <el-button type="primary" @click="reset_c">重 置</el-button>
        <el-button type="primary" @click="create">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="资产信息编辑"
      v-if="$route.path === '/caption/assets'"
      width="40%"
      :show-close="false"
      :close-on-click-modal="false"
      :lock-scroll="true"
      :visible.sync="dialogFormVisible_edmit"
    >
      <el-form
        ref="form"
        :model="form"
        label-width="5.625rem"
        class="d-flex flex-column w-10 p-2 pt-0"
      >
        <el-col :span="24">
          <el-tabs type="border-card">
            <el-tab-pane label="资产名称编辑">
              <el-col :span="24" class="d-flex flex-column">
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">资产名称</label>
                  <div class="el-form-item__content">
                    <el-input v-model="form.zcmzName" clearable></el-input>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="非经营行资产编辑">
              <el-col :span="24">
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">计量单位</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzJilangdanwei" clearable placeholder="请输入计量单位"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">单价</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzDanjian" clearable placeholder="请输入单价"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">现今价值</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzXianzhi" clearable placeholder="请输入现今价值"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">规则型号</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzXinghao" clearable placeholder="请输入规则型号"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">资产来源</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzLaiyuan" clearable placeholder="请输入资产来源"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">使用部门</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzDepartment" clearable placeholder="请输入使用部门"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">产品状态</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzZhuangtai" clearable placeholder="请输入产品状态"></el-input>
                    </div>
                  </div>
                </el-col>
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">数量</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzShuliang" clearable placeholder="请输入数量"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">变动情况</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzBiandongqingkuang"
                        clearable
                        placeholder="请输入变动情况"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">品牌</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzPinpai" clearable placeholder="请输入品牌"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">构建时间</label>
                    <div class="el-form-item__content">
                      <el-date-picker
                        v-model="form.zjtzGoujianshijian"
                        type="date"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        placeholder="选择日期"
                        clearable
                      ></el-date-picker>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">预计年限</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzYvjinianxian" clearable placeholder="请输入预计年限"></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">使用人</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zjtzPeople" clearable placeholder="请输入使用人"></el-input>
                    </div>
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24" class="mb-2">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">备注</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-input type="textarea" :rows="4" v-model="form.zjtzBeizhu"></el-input>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="经营性资产编辑">
              <el-col :span="24">
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">承租人</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyChengzhuren" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同期限</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyHetongqixian" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同状态</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyZhuangtai" clearable></el-input>
                    </div>
                  </div>
                </el-col>
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">签订合同</label>
                    <div class="el-form-item__content">
                      <el-select
                        v-model="form.zcjyHetong"
                        clearable
                        placeholder="请选择想要查看的村"
                        @change="get_types(true)"
                      >
                        <el-option
                          v-for="(item, index) in [{name: '有', value: true}, {name: '无', value: false}]"
                          :key="index"
                          :label="item.name"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">支付情况</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyZhifuqinkuang" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同金额</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyHetongjine" clearable></el-input>
                    </div>
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24" class="mb-2">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">备注</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-input type="textarea" :rows="4" v-model="form.zcjyBeizhu"></el-input>
                  </div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同照片</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-upload
                      ref="upload_edmit"
                      list-type="picture-card"
                      :file-list="form.src"
                      :on-preview="handlePictureCardPreview"
                      :on-remove="handleRemove"
                      :auto-upload="false"
                      :on-change="file_change"
                      :http-request="uploadFile"
                      :data="form"
                      :multiple="true"
                    >
                      <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible" size="tiny">
                      <img width="100%" v-if="form.src" :src="form.src" alt />
                    </el-dialog>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel_u">取 消</el-button>
        <el-button type="primary" @click="reset_u">重 置</el-button>
        <el-button type="primary" @click="updata_save">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="资产信息详情"
      v-if="$route.path === '/caption/assets'"
      width="40%"
      :show-close="true"
      :lock-scroll="true"
      :visible.sync="dialogFormVisible_all"
    >
      <el-form
        ref="form"
        :model="form"
        label-width="5.625rem"
        class="d-flex flex-column w-10 p-2 pt-0"
      >
        <el-col :span="24">
          <el-tabs type="border-card">
            <el-tab-pane label="资产名称编辑">
              <el-col :span="24" class="d-flex flex-column">
                <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">资产名称</label>
                  <div class="el-form-item__content">
                    <el-input v-model="form.zcmzName" :disabled="true" clearable></el-input>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="非经营行资产编辑">
              <el-col :span="24">
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">计量单位</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzJilangdanwei"
                        :disabled="true"
                        clearable
                        placeholder="请输入计量单位"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">单价</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzDanjian"
                        :disabled="true"
                        clearable
                        placeholder="请输入单价"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">现今价值</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzXianzhi"
                        :disabled="true"
                        clearable
                        placeholder="请输入现今价值"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">规则型号</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzXinghao"
                        :disabled="true"
                        clearable
                        placeholder="请输入规则型号"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">资产来源</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzLaiyuan"
                        :disabled="true"
                        clearable
                        placeholder="请输入资产来源"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">使用部门</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzDepartment"
                        :disabled="true"
                        clearable
                        placeholder="请输入使用部门"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">产品状态</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzZhuangtai"
                        :disabled="true"
                        clearable
                        placeholder="请输入产品状态"
                      ></el-input>
                    </div>
                  </div>
                </el-col>
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">数量</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzShuliang"
                        :disabled="true"
                        clearable
                        placeholder="请输入数量"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">变动情况</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzBiandongqingkuang"
                        :disabled="true"
                        clearable
                        placeholder="请输入变动情况"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">品牌</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzPinpai"
                        :disabled="true"
                        clearable
                        placeholder="请输入品牌"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">构建时间</label>
                    <div class="el-form-item__content">
                      <el-date-picker
                        v-model="form.zjtzGoujianshijian"
                        type="date"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        placeholder="选择日期"
                        clearable
                        :disabled="true"
                      ></el-date-picker>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">预计年限</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzYvjinianxian"
                        :disabled="true"
                        clearable
                        placeholder="请输入预计年限"
                      ></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">使用人</label>
                    <div class="el-form-item__content">
                      <el-input
                        v-model="form.zjtzPeople"
                        :disabled="true"
                        clearable
                        placeholder="请输入使用人"
                      ></el-input>
                    </div>
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24" class="mb-2">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">备注</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-input type="textarea" :rows="4" :disabled="true" v-model="form.zjtzBeizhu"></el-input>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="经营性资产编辑">
              <el-col :span="24">
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">承租人</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyChengzhuren" :disabled="true" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同期限</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyHetongqixian" :disabled="true" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-center">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同状态</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyZhuangtai" :disabled="true" clearable></el-input>
                    </div>
                  </div>
                </el-col>
                <el-col :span="12" class="d-flex flex-column ai-start">
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">签订合同</label>
                    <div class="el-form-item__content">
                      <el-select
                        v-model="form.zcjyHetong"
                        clearable
                        :disabled="true"
                        placeholder="请选择想要查看的村"
                        @change="get_types(true)"
                      >
                        <el-option
                          v-for="(item, index) in [{name: '有', value: true}, {name: '无', value: false}]"
                          :key="index"
                          :label="item.name"
                          :value="item.value"
                        ></el-option>
                      </el-select>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">支付情况</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyZhifuqinkuang" :disabled="true" clearable></el-input>
                    </div>
                  </div>
                  <div class="el-form-item el-form-item--medium mb-2 w-10 d-flex jc-start">
                    <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同金额</label>
                    <div class="el-form-item__content">
                      <el-input v-model="form.zcjyHetongjine" disabled="true" clearable></el-input>
                    </div>
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24" class="mb-2">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">备注</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-input type="textarea" :rows="4" v-model="form.zcjyBeizhu" :disabled="true"></el-input>
                  </div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="el-form-item el-form-item--medium d-flex jc-start w-10 d-flex jc-start">
                  <label for="date" class="el-form-item__label" style="width: 5.625rem;">合同照片</label>
                  <div class="el-form-item__content flex-1 pr-2">
                    <el-upload
                      ref="upload_edmit"
                      list-type="picture-card"
                      :file-list="form.src"
                      :on-preview="handlePictureCardPreview"
                      :on-remove="handleRemove"
                      :auto-upload="false"
                      :on-change="file_change"
                      :http-request="uploadFile"
                      :data="form"
                      :multiple="true"
                      :disabled="true"
                    >
                      <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible" size="tiny">
                      <img width="100%" v-if="form.src" :src="form.src" alt />
                    </el-dialog>
                  </div>
                </div>
              </el-col>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible_all = false">取 消</el-button>
      </div>
    </el-dialog>
  </el-row>
</template>

<script>
export default {
  data() {
    return {
      model: {},
      admin: {},
      obj: {},
      items: [
        //表格内容
      ],
      init_items: [
        //原始表格渲染数据
      ],
      pagination: {
        current_page: 1,
        page_sizes: [20, 30, 50, 100],
        page_size: 20,
        total: 0,
        page_length: 0
      },
      loading: true,
      formLabelWidth: "100px",
      form: {
        //弹出框内容
        standard: {}
      },
      query: {
        //检索对象
        mRegion: "1349"
      },
      //序列id
      index_id: 0,
      index: 0,
      //对应村
      villageAtt: [],
      villageAtt_form: [],
      //对应镇
      townAtt: [],
      townAtt_form: [],
      //对应组
      groupAtt: [],
      groupAtt_form: [],
      //根据村选类型
      region: {},
      //对应类型
      aTypeAtt: [],
      types: [],
      //村信息
      villMes: "",
      //多删数组
      delAtt: [],
      multipleSelection: [],
      //文件上传
      fileList: [],
      fileList_file: [],
      formData: {},
      type: 1,
      file_form: {},
      url: "assetsdetails/importZichantaizhangExcel",
      url_account: "assetsdetails/importZichantaizhangExcel",
      url_manage: "assetsdetails/importZiChanJingYingExcel",
      //删除的对象
      del_obj: {},
      delMany: {},
      //模态框
      dialogFormVisible_create: false,
      dialogFormVisible_edmit: false,
      dialogFormVisible_all: false
    };
  },

  methods: {
    setQuery() {
      if (this.admin.mType == 4) {
        this.query.mRegion = this.admin.mRegion;
        this.query.mZhenid = this.admin.mZhenid;
        this.get_villageAtt();
      }
      if (this.admin.mType == 5) {
        this.query.mRegion = this.admin.mRegion;
        this.query.mZhenid = this.admin.mZhenid;
        this.query.mVillageid = this.admin.mVillageid;
      }
    },
    setObj(obj) {
      obj.mRegion = "1349";
      obj.startPage = this.pagination.current_page;
      obj.pageSize = this.pagination.page_size;
    },
    async get_aType(flag) {
      if (false) {
        const res = await this.$http.get("assetsdetails/quaryAllType");
        this.aTypeAtt_form = res.data.Type;
      } else {
        this.region.forEach(item => {
          if (item.village.villageId == this.query.mVillageid) {
            this.aTypeAtt = item.Assetstype;
          }
        });
      }
    },
    async get_townAtt(flag) {
      let res;
      if (flag) {
        res = await this.$http.get(`/caiwu/findzhenByRegionId/1349`);
        this.townAtt_form = res.data.data;
      } else {
        res = await this.$http.get(
          `/caiwu/findzhenByRegionId/${this.query.mRegion}`
        );
        this.townAtt = res.data.data;
      }
    },
    async get_villageAtt(flag) {
      let res;
      if (flag) {
        res = await this.$http.get(
          `/caiwu/findzhenByZhenId/${this.form.mZhenid}`
        );
        this.villageAtt_form = res.data.data;
      } else {
        res = await this.$http.get(
          `/caiwu/findzhenByZhenId/${this.query.mZhenid}`
        );
        this.villageAtt = res.data.data;
      }
    },
    async get_groupAtt(flag) {
      let res;
      if (flag) {
        res = await this.$http.get(`/caiwu/findZu/${this.form.villageId}`);
        this.groupAtt_form = res.data.data;
      } else {
        res = await this.$http.get(`/caiwu/findZu/${this.query.mVillageid}`);
        this.groupAtt = res.data.data;
      }
    },
    //请求数据
    async fetch(obj) {
      this.setObj(obj);
      const res = await this.$http.post(
        "/assetsdetails/Zichanmingzi",
        this.Qs.stringify(obj)
      );
      if (obj.mType) {
        let { region } = res.data;
        this.region = region;
      }
      if (res.data.data) {
        this.init_items = res.data;
        Array.isArray(res.data.data) &&
          res.data.data.forEach((item, index) => {
            item.manage =
              res.data.data2[index] && res.data.data2[index].Zichanjingying
                ? res.data.data2[index].Zichanjingying
                : {};
            item.ledger =
              res.data.data2[index] && res.data.data2[index].Zichantaizhang
                ? res.data.data2[index].Zichantaizhang
                : {};
            let att = [];
            if (item.manage && item.manage.zcjyPhoto) {
              item.src = item.manage.zcjyPhoto.split(",");
              item.src.forEach(item => {
                if (item) {
                  att.push({
                    url: `${this.assetsURL}ZiChanJingYing/${item}`,
                    name: `${item}`
                  });
                }
              });
            }
            item.src = att;
            if (item.assets.aVillageid) {
              item.villName = this.get_villName(item.assets.aVillageid);
            }
          });
        if (res.data.data2) {
          Array.isArray(res.data.data) &&
            res.data.data.forEach((item, index) => {
              item.standard = res.data.data2[index];
              let obj = res.data.data2[index];
              for (let item1 in obj) {
                if (obj[item1]) {
                  item[item1] = obj[item1];
                  let obj1 = obj[item1];
                  for (let item2 in obj1) {
                    if (obj1[item2]) {
                      item[item2] = obj1[item2];
                    }
                  }
                }
              }
            });
        }
        this.items = res.data.data;
        this.loading = false;
        this.up_pagination();
        if (
          this.$util.getCookie("current_page") !==
          String(this.pagination.current_page)
        ) {
          this.handleCurrentChange(this.$util.getCookie("current_page"));
        }
      } else {
        this.items = [];
        if (res.status == 200) {
          this.loading = false;
        }
      }
    },
    async get_villMes() {
      const res = await this.$http.get("/h/cacheVillage");
      this.villMes = res.data.data;
    },
    get_villName(id) {
      let res;
      this.villMes.forEach(item => {
        if (item.villageId == id) {
          res = item.vName;
        }
      });
      return res;
    },
    handleSelectionChange(val) {
      let att = [];
      this.multipleSelection = val;
      this.multipleSelection.forEach(item => {
        let { zcmzId } = item;
        att.push(zcmzId);
      });
      this.delAtt = att;
    },
    setIndex() {
      this.$basicMes.forEach((item, index) => {
        if (item.name == this.query.town) {
          this.villageAtt = this.$basicMes[index].village;
        }
      });
    },
    get_delObj() {
      let { managerId } = this.admin;
      this.del_obj = { managerId };
    },
    get_delMany() {
      this.delMany = this.delAtt;
    },
    del(index, name) {
      this.get_delObj();
      this.index_id = index;
      this.form = this.items[index];
      this.del_obj.capitalDetailsId = this.form.CapitalDetails_Id;
      this.$confirm(
        `此操作将永久删除 ${this.items[index][name]}, 是否继续?`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          center: true
        }
      )
        .then(async index => {
          const res = await this.$http.delete(
            `/assetsdetails/ZichanmingziDeleteOne/${this.form.zcmzId}/${this.admin.managerId}`
          );
          if (res.status === 200) {
            this.$message({
              type: "success",
              message: "删除成功!"
            });
            this.to_query();
          } else {
            this.$message({
              type: "error",
              message: "删除失败!"
            });
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    updata(index, flag) {
      this.dealFormItemForEdmit(index);
      if (flag) {
        this.dialogFormVisible_all = true;
      } else {
        this.dialogFormVisible_edmit = true;
      }
    },
    dealFormItemForEdmit(index) {
      this.form = JSON.parse(JSON.stringify(this.items[index]));
      let { zcmzId: ZCMZ_Id, zcmzName, src } = this.form;
      let {
        aVillageid: villageId,
        aZu: zuId,
        assetsId: Assets_Id
      } = this.form.assets;
      let {
        zjtzJilangdanwei,
        zjtzShuliang,
        zjtzDanjian,
        zjtzBiandongqingkuang,
        zjtzXianzhi,
        zjtzPinpai,
        zjtzXinghao,
        zjtzGoujianshijian,
        zjtzLaiyuan,
        zjtzYvjinianxian,
        zjtzDepartment,
        zjtzPeople,
        zjtzBeizhu,
        zjtzZhuangtai,
        zjtzId
      } = this.form.ledger;
      let {
        zcjyZhuangtai,
        zcjyChengzhuren,
        zcjyHetong,
        zcjyHetongqixian,
        zcjyHetongjine,
        zcjyZhifuqinkuang,
        zcjyBeizhu,
        zcjyId
      } = this.form.manage;
      this.form = {
        ZCMZ_Id,
        zcmzName,
        src,
        villageId,
        zuId,
        Assets_Id,

        zjtzJilangdanwei,
        zjtzShuliang,
        zjtzDanjian,
        zjtzBiandongqingkuang,
        zjtzXianzhi,
        zjtzPinpai,
        zjtzXinghao,
        zjtzGoujianshijian,
        zjtzLaiyuan,
        zjtzYvjinianxian,
        zjtzDepartment,
        zjtzPeople,
        zjtzBeizhu,
        zjtzZhuangtai,
        zjtzId,

        zcjyZhuangtai,
        zcjyChengzhuren,
        zcjyHetong,
        zcjyHetongqixian,
        zcjyHetongjine,
        zcjyZhifuqinkuang,
        zcjyBeizhu,
        zcjyId
      };
      this.initImage(this.form.src);
    },
    initImage(imgAtt) {
      imgAtt.forEach(item => {
        if (item) {
          let file = {};
          this.appandFile(file, file => (item.file = file), item.url);
        }
      });
      this.fileList = imgAtt;
    },
    async del_multip(name) {
      if (!this.delAtt.length) {
        return;
      }
      this.get_delMany();
      let str = "";
      this.multipleSelection.forEach(item => {
        str += item[name] + "\t\t";
      });

      this.$confirm(`此操作将永久删除 ${str}, 是否继续?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true
      })
        .then(async index => {
          const res = await this.$http.delete(
            `/assetsdetails/ZichanmingziDeleteMany/${this.delAtt.toString()}/${
              this.admin.managerId
            }`
          );
          console.log(".....////");
          console.log(res);
          if (res.status === 200) {
            this.$message({
              type: "success",
              message: "删除成功!"
            });
            this.to_query();
          } else {
            this.$message({
              type: "error",
              message: "删除失败!"
            });
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },

    //选择文件
    set_files_form() {
      let obj = { managerId: this.admin.managerId };
      this.file_form = obj;
      console.log(obj);
      console.log(this.file_form);
    },
    set_src(value) {
      if (value == 1) {
        this.url = this.url_account;
      } else if (value == 2) {
        this.url = this.url_manage;
      }
    },
    //文件上传
    submitUpload() {
      this.$refs.upload.submit();
    },
    success(res, file, files) {
      if (res.status === "成功") {
        this.$message({
          type: "success",
          message: "上传成功"
        });
      } else {
        this.$message({
          type: "error",
          message: res.status
        });
      }
      this.to_query();
    },
    handlePreview(file) {
      console.log(file);
    },
    //分页功能
    up_pagination() {
      this.pagination.page_length = Math.ceil(
        this.init_items.count / this.pagination.current_page
      );
      this.pagination.total = this.init_items.count;
    },
    handleSizeChange(val) {
      this.pagination.page_size = val;
      this.to_query();
    },
    async handleCurrentChange(val) {
      this.pagination.current_page = val;
      this.$util.setCookie("current_page", this.pagination.current_page);
      this.to_query();
    },
    //query
    to_query() {
      let obj = JSON.parse(JSON.stringify(this.query));
      this.fetch(obj);
    },

    //create
    async name_create() {
      this.set_form(this.form);
      const res = await this.$http.post(
        `/assets/addzichanmingzi`,
        this.Qs.stringify(this.form)
      );
      if (res.status == 200) {
        this.$message({
          type: "success",
          message: `${res.data.status}`
        });
        this.tabValue = "account";
        this.create = this.account_create;
        this.account_flag = false;
        this.message_flag = false;
        this.name_flag = true;
        this.$notify({
          title: "提示",
          message: "这是一条不会自动关闭的消息",
          duration: 0
        });
        this.form["zjtzName"] = res.data.zichanmingzi.zcmzId;
      } else {
        this.$message({
          message: res.data.status,
          type: "warnning"
        });
      }
    },
    async create() {
      let obj = this.set_form();
      let res = {};
      if (this.fileList.length > 0) {
        this.formDate = new FormData();
        this.$refs.upload_create.submit();
        for (let item in obj) {
          this.formDate.append(item, obj[item]);
        }
        res = await this.$http.post("/assets/addZichan", this.formDate);
        this.file = {};
      } else {
        res = await this.$http.post(
          "/assets/addZichan",
          this.Qs.stringify(obj)
        );
      }
      if (res.status === 200) {
        this.$message({
          message: `${res.data.message}`,
          type: "success"
        });
        this.to_query();
        this.dialogFormVisible_create = false;
      }
    },
    reset_c() {
      this.$confirm("确定重置新增数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "info"
      }).then(() => {
        this.$message({
          type: "success",
          message: "已重置"
        });
        this.form = {};
      });
    },
    async show_init() {
      this.get_aType(true);
      switch (this.admin.mType) {
        case 2:
          this.get_townAtt(true);
          break;
        case 3:
          break;
        case 4:
          await this.get_townAtt(true);
          this.form.mZhenid = this.admin.mZhenid;
          await this.get_villageAtt(true);
          break;
        case 5:
          await this.get_townAtt(true);
          this.form.mZhenid = this.admin.mZhenid;
          await this.get_villageAtt(true);
          this.form.villageId = this.admin.mVillageid;
          this.get_groupAtt(true);
          break;
      }
    },
    show_form() {
      this.clearObj(this.form);
      this.show_init();
      // this.get_aType(true);
      this.dialogFormVisible_create = true;
      // this.form.mRegion = "1349";
      // this.get_townAtt(true);
    },
    set_form() {
      this.form.managerId = this.admin.managerId;
      let obj = JSON.parse(JSON.stringify(this.form));
      for (let item in obj) {
        if (!obj[item] || item == "src") {
          delete obj[item];
        }
      }
      return obj;
    },
    async uploadFile(files) {
      this.formDate.append("file", files.file);
    },
    cancel_c() {
      this.$confirm("取消添加将不会保存该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "已取消！"
          });
          this.dialogFormVisible_create = false;
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消操作"
          });
        });
    },
    success_c(res, file, files) {
      if (res.status == "新增成功") {
        this.$message({
          type: "success",
          message: `新增成功!!`
        });
      }
    },
    handleRemove(file, fileList) {
      console.log(fileList, `-------------Remove`);
      this.fileList = fileList;
    },
    file_change(file, fileList) {
      this.fileList = fileList;
      console.log(fileList, `-------------change`);
    },
    async updata_save() {
      let obj = this.set_form();
      let res = {};
      if (this.fileList.length > 0) {
        this.formDate = new FormData();
        this.fileList.forEach(file => {
          if (file.file) {
            this.formDate.append("file", file.file);
          } else {
            this.formDate.append("file", file.raw);
          }
        });
        for (let item in obj) {
          this.formDate.append(item, obj[item]);
        }
        res = await this.$http.post("/assets/updateZichan", this.formDate);
        this.file = {};
      } else {
        res = await this.$http.post(
          "/assets/updateZichan",
          this.Qs.stringify(obj)
        );
      }
      if (res.status === 200) {
        this.$message({
          message: `${res.data.message}`,
          type: "success"
        });
        this.to_query();
        this.dialogFormVisible_edmit = false;
      } else {
        this.$message({
          message: "编辑失败",
          type: "error"
        });
      }
    },
    reset_u() {
      this.$confirm("确定重置编辑数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "info"
      }).then(() => {
        this.$message({
          type: "success",
          message: "已重置"
        });
        for (let item in this.form) {
          if (item !== "_id") {
            this.form[item] = "";
          }
        }
      });
    },
    cancel_u() {
      this.$confirm("取消添加将不会保存该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "已取消！"
          });
          this.dialogFormVisible_edmit = false;
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消操作"
          });
        });
    }
  },
  created() {
    this.admin = this.$util.handleLocalStorage("get", "admin");
    this.pagination.current_page = 1;
    this.$util.setCookie("current_page", this.pagination.current_page);
    this.get_townAtt();
    this.setQuery();
    let obj = {
      mType: this.admin.mType,
      ...this.query
    };
    this.get_villMes();
    this.fetch(obj);
  }
};
</script>

<style lang="scss" scoped>
.my-scroll-bar {
  height: 200px;
}
.query-form {
  padding-top: 20px;
  margin-bottom: 20px;
  background-color: #f2f2f2;
  display: flex;
  justify-content: flex-start;
}
.el-form--inline .el-form-item {
  display: inline-block;
  margin-right: 10px;
  vertical-align: top;
}
</style>

